<?PHP
if (!session_start()) { session_start(); };
/*if (!isset($_SESSION['lgnapproved'])) {
	die(header('Location: login.php'));
}*/
include("functions.php");
include("cnnxn.php");
connect();

$SQLview='SELECT * FROM Tournaments ORDER BY StartDate DESC;';
//print $SQLview;
$sendit_view=mysqli_query($db,$SQLview) or die(mysqli_error($db));

$thisYear=date("Y");
$years=$thisYear-3;
$followingYears=$thisYear+3;

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>daleclark.net</title>
<link type="text/css" rel="stylesheet" href="adminstyles.css" />
</head>
<body>
<div id="adminwrapper">
<div id="adminlogo"></div>
<?PHP navigation(); ?>
<div id="admincontent">
<h3>Tournaments</h3>

<div style="float:left; width:500px; padding-right:25px; margin-right:25px; border-right:1px solid #FFFFFF;">

<?PHP 
$backgroundcolor="#2883D4";
while ($RSview=mysqli_fetch_object($sendit_view)) {
	
	if ($backgroundcolor=="#2883D4") {
		$backgroundcolor="#2F93E9";
	} else {
		$backgroundcolor="#2883D4";
	}
	if (isset($_GET['er']) && $_GET['er']==$RSview->TournamentID) {
		print '<p style="margin-bottom:0px; color:#990000;">There are still Events linked to this Tournament. Please remove those first.</p>';
	}
	print '<div style="background:'.$backgroundcolor.'; width:500px; padding:2px 2px 2px 5px;"><span class="deletespan"><a href="Tournaments_del.php?tid='.$RSview->TournamentID.'" class="deletelink" title="DELETE" onclick="return confirm(\'Are sure you want to PERMANENTLY DELETE this Tournament?\')"><img src="../images/icon_delete.png" height="12px" border="0" /></a></span><span class="column01span"><a href="Tournaments_mod.php?id='.stripslashes($RSview->TournamentID).'">'.$RSview->StartDate.'</a></span><span class="column02span"><a href="Events_viewall.php?tid='.$RSview->TournamentID.'">Events</a></span><div class="clear"></div></div>';
}
?>

<div class="clear"></div>
<p>&nbsp;</p>
</div>
<div style="float:left; width:500px;">
<h3>Add Tournament</h3>

<form name="addForm" method="POST" action="Tournaments_add.php">

<p><span class="label">Start Date</span><span class="inputbox">day: <select name="eventdate_day">
<option value="01"<?PHP if (date("d")==01) { print ' selected'; } ?>>01</option>
<option value="02"<?PHP if (date("d")==02) { print ' selected'; } ?>>02</option>
<option value="03"<?PHP if (date("d")==03) { print ' selected'; } ?>>03</option>
<option value="04"<?PHP if (date("d")==04) { print ' selected'; } ?>>04</option>
<option value="05"<?PHP if (date("d")==05) { print ' selected'; } ?>>05</option>
<option value="06"<?PHP if (date("d")==06) { print ' selected'; } ?>>06</option>
<option value="07"<?PHP if (date("d")==07) { print ' selected'; } ?>>07</option>
<option value="08"<?PHP if (date("d")==08) { print ' selected'; } ?>>08</option>
<option value="09"<?PHP if (date("d")==09) { print ' selected'; } ?>>09</option>
<option value="10"<?PHP if (date("d")==10) { print ' selected'; } ?>>10</option>
<option value="11"<?PHP if (date("d")==11) { print ' selected'; } ?>>11</option>
<option value="12"<?PHP if (date("d")==12) { print ' selected'; } ?>>12</option>
<option value="13"<?PHP if (date("d")==13) { print ' selected'; } ?>>13</option>
<option value="14"<?PHP if (date("d")==14) { print ' selected'; } ?>>14</option>
<option value="15"<?PHP if (date("d")==15) { print ' selected'; } ?>>15</option>
<option value="16"<?PHP if (date("d")==16) { print ' selected'; } ?>>16</option>
<option value="17"<?PHP if (date("d")==17) { print ' selected'; } ?>>17</option>
<option value="18"<?PHP if (date("d")==18) { print ' selected'; } ?>>18</option>
<option value="19"<?PHP if (date("d")==19) { print ' selected'; } ?>>19</option>
<option value="20"<?PHP if (date("d")==20) { print ' selected'; } ?>>20</option>
<option value="21"<?PHP if (date("d")==21) { print ' selected'; } ?>>21</option>
<option value="22"<?PHP if (date("d")==22) { print ' selected'; } ?>>22</option>
<option value="23"<?PHP if (date("d")==23) { print ' selected'; } ?>>23</option>
<option value="24"<?PHP if (date("d")==24) { print ' selected'; } ?>>24</option>
<option value="25"<?PHP if (date("d")==25) { print ' selected'; } ?>>25</option>
<option value="26"<?PHP if (date("d")==26) { print ' selected'; } ?>>26</option>
<option value="27"<?PHP if (date("d")==27) { print ' selected'; } ?>>27</option>
<option value="28"<?PHP if (date("d")==28) { print ' selected'; } ?>>28</option>
<option value="29"<?PHP if (date("d")==29) { print ' selected'; } ?>>29</option>
<option value="30"<?PHP if (date("d")==30) { print ' selected'; } ?>>30</option>
<option value="31"<?PHP if (date("d")==31) { print ' selected'; } ?>>31</option>
</select>&nbsp;month: <select name="eventdate_month">
<option value="01"<?PHP if (date("m")==01) { print ' selected'; } ?>>01</option>
<option value="02"<?PHP if (date("m")==02) { print ' selected'; } ?>>02</option>
<option value="03"<?PHP if (date("m")==03) { print ' selected'; } ?>>03</option>
<option value="04"<?PHP if (date("m")==04) { print ' selected'; } ?>>04</option>
<option value="05"<?PHP if (date("m")==05) { print ' selected'; } ?>>05</option>
<option value="06"<?PHP if (date("m")==06) { print ' selected'; } ?>>06</option>
<option value="07"<?PHP if (date("m")==07) { print ' selected'; } ?>>07</option>
<option value="08"<?PHP if (date("m")==08) { print ' selected'; } ?>>08</option>
<option value="09"<?PHP if (date("m")==09) { print ' selected'; } ?>>09</option>
<option value="10"<?PHP if (date("m")==10) { print ' selected'; } ?>>10</option>
<option value="11"<?PHP if (date("m")==11) { print ' selected'; } ?>>11</option>
<option value="12"<?PHP if (date("m")==12) { print ' selected'; } ?>>12</option>
</select>&nbsp;year: <select name="eventdate_year">
<?PHP
while ($years<=$followingYears) {
	$years++;
	print '<option value="'.$years.'"';
	if ($years==$thisYear) {
		print ' selected';
	}
	print '> '.$years.' </option>';
}
?>
</select></span></p>

<p><span class="label">Name (<em>not required</em>)</span><span class="inputbox"><input name="Name" type="text" /></span></p>
<p><span class="label">Is US Open Qualifier</span><span class="inputbox"><input name="IsUSOpenQualifier" type="checkbox" value="1" /></span></p>
<input type="submit" value="submit" name="submit" />
</form>

</div>

</div>
</div>
</body>
</html>
<?PHP
mysqli_close($db);
?>